package util

import (
	"crypto/sha1"
	"encoding/hex"
	"encoding/json"
	"trade_api/models/request"

	"go.uber.org/zap"
)

// GenerateTradeRecordEnvidence 生成envidence 哈希的值
func GenerateTradeRecordEnvidence(createPortalProverReq *request.CreateTradeProverReq) (hashText string, err error) {
	portalDataBytes, err := json.Marshal(createPortalProverReq)
	if err != nil {
		return "", err
	}
	ins := sha1.New()
	ins.Write(portalDataBytes)
	result := hex.EncodeToString(ins.Sum(nil))
	zap.L().Debug(result)
	return result, nil
}
